<?php

namespace App\Repositories;

use App\Models\ServiceBank;

class ServiceBankRepository extends BaseRepository
{
    public function model()
    {
        return ServiceBank::class;
    }

    /**
     * 获取服务站体现银行信息列表
     * Date: 2018/05/10
     * @param $service_id
     * @param $limit
     * @param $name
     * @param $phone
     * @author Tenny
     * @return \Illuminate\Database\Eloquent\Collection|static[]
     */
    public function getServiceBanks($service_id = false, $limit = false, $name = false, $phone = false)
    {
        if ($service_id !== false) {
            $this->where('service_id', '=', $service_id);
        }
        if ($name !== false) {
            $this->where('name', '=', $name);
        }
        if ($phone !== false) {
            $this->where('phone', '=', $phone);
        }
        $serviceBanks = $this->paginate($limit);
        return $serviceBanks;
    }

    /**
     * 根据服务站体现银行信息详情
     * Date: 2018/05/21
     * @param $serviceBank_id
     * @return \Illuminate\Database\Eloquent\Collection|static[]
     */
    public function ServiceBankInfo($serviceBank_id)
    {
        $serviceBankInfos = \DB::table('serviceBank as c')
            ->select(['c.id', 'c.avatar', 'c.name', 'c.phone', 's.designation as service_name', 'c.is_authentication', 'c.jurisdiction'])
            ->leftJoin('service as s', 's.id', '=', 'c.service_id')
            ->where('c.id', '=', $serviceBank_id)
            ->first();
        return $serviceBankInfos;
    }

    protected function serialization(array $attributes)
    {
        // TODO: Implement serialization() method.
    }
}